﻿<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/design.Master" CodeBehind="details.aspx.vb" Inherits="CakeThatIBaked.WebForm1" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    Rate the Cake (change your rating at anytime)<asp:RadioButtonList ID="cakeRate" runat="server" RepeatDirection="Horizontal" 
        AutoPostBack="True">
    <asp:ListItem Value="1"></asp:ListItem>
    <asp:ListItem Value="2">2</asp:ListItem>
    <asp:ListItem Value="3">3</asp:ListItem>
    <asp:ListItem Value="4">4</asp:ListItem>
    <asp:ListItem Value="5">5</asp:ListItem>
                                </asp:RadioButtonList>


    <asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1">
        
            <ItemTemplate>
                <!-- Main Container -->
                <div id = "container">
                    <!-- Left Column (Picture) -->
                    <div id = "col1">
                        <img src = "<%# eval("CakePictureMain") %>" width = 310px height = 310px />
                    </div>

                    <!-- Right Column Contents -->
                    <div id = "col2">
                        
                        <!-- Top Cont -->
                        <div id="topcont">
                            <!-- Cont for Title and Author -->
                            <div id = "tleft">
                                <h2><%# Eval("CakeTitle")%></h2>
                                <h3> By <%# Eval("UserName")%></h3>
                            </div>

                            <!-- Recipe Tags -->
                            <div id = "tright">
                                <asp:Repeater ID="Repeater2" runat="server" DataSourceID="recipeSource">
                                    <ItemTemplate>
                                        <%# Eval("RecipeItem")%>
                                        |
                                    </ItemTemplate>
                                </asp:Repeater>
                            </div>
                        
                        </div>

                         <!-- CSS Clear Fix -->
                         <br class="clearFix"  />

                         <!-- User Description Container -->
                         <div id = "middlecont">
                            <%# Eval("CakeDescription")%>
                         </div>

                        <!-- CSS Clear Fix -->
                        <br class="clearFix"  />

                        <!-- Container for Tags and Rating -->
                        <div id = "bottomcont">
            
                            <div id = "bleft">
                                Cake Rating: <%# CakeThatIBaked.Class1.showRating(Eval("CakeRating"))%>
                                                                
                            </div>

                            <div id = "tagright">
                                <!-- Tags -->
                                <asp:LoginView ID="LoginView1" runat="server">
                                <LoggedInTemplate><%# createlink()%>
                                <br />
                                </LoggedInTemplate>
                                </asp:LoginView>
                                <asp:Repeater ID="TagRepeater" runat="server" DataSourceID="NewCakeTags">
                                    <ItemTemplate>
                                    <%# getTags(Eval("CountOfCT_FID"), Eval("TagName"))%>
                                        
                                    </ItemTemplate>
                                </asp:Repeater>
                            </div>

                        </div>

                    </div>
                    <br class="clearFix" />                    
                </div>
                <!-- Comments Section -->
                <h2 style="font-family: 'Bad Script', cursive; "> Comments </h2>
                <br />
                <asp:LoginView ID="LoginView2" runat="server">
                                <LoggedInTemplate><%# createlink2()%>
                                <br />
                                </LoggedInTemplate>
                                </asp:LoginView>
                <asp:Repeater ID="Repeater3" runat="server" DataSourceID="CommentSource">
                    <HeaderTemplate>
                        <ol class="commentlist">
                    </HeaderTemplate>

                    <ItemTemplate>
                        <li class="commentblock">
                            <div class="pictureholder">
                                <img src=<%# Eval("ProfilePic") %> width=80 height=80 />
                            </div>
                             <%# Eval("Comment")%>
                        </li>                                            
                    </ItemTemplate>

                    <AlternatingItemTemplate>
                         <li class="commentblock2">
                            <div class="pictureholder">
                                <img src=<%# Eval("ProfilePic") %> width=80 height=80 />
                            </div>
                             <%# Eval("Comment")%>
                        </li>
                    </AlternatingItemTemplate>

                    <FooterTemplate>
                        </ol>
                    </FooterTemplate>
                </asp:Repeater>

            </ItemTemplate>

    </asp:Repeater>
    
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:CakeConnection %>" 
        ProviderName="<%$ ConnectionStrings:CakeConnection.ProviderName %>" 
        
        SelectCommand="SELECT [ID], [CakeTitle], [Author], [CakeDescription], [CakeRating], [CakePictureMain], [Score], [UserName] FROM [CakeUserView] WHERE ([ID] = ?)">
        <SelectParameters>
            <asp:QueryStringParameter Name="ID" QueryStringField="cakeNo" Type="Int32" />
        </SelectParameters>
    </asp:SqlDataSource>


    <asp:SqlDataSource ID="recipeSource" runat="server" 
        ConnectionString="<%$ ConnectionStrings:CakeConnection %>" 
        ProviderName="<%$ ConnectionStrings:CakeConnection.ProviderName %>" 
        SelectCommand="SELECT [CakeTitle], [RecipeItem], [ID] FROM [RecipeView] WHERE ([ID] = ?)">
        <SelectParameters>
            <asp:QueryStringParameter Name="ID" QueryStringField="cakeNo" Type="Int32" />
        </SelectParameters>
    </asp:SqlDataSource>

    <asp:SqlDataSource ID="CommentSource" runat="server" 
        ConnectionString="<%$ ConnectionStrings:CakeConnection %>" 
        ProviderName="<%$ ConnectionStrings:CakeConnection.ProviderName %>" 
        SelectCommand="SELECT [C_FID], [UserName], [Comment], [ProfilePic] FROM [CakeCommenttView] WHERE ([C_FID] = ?)">
        <SelectParameters>
            <asp:QueryStringParameter Name="C_FID" QueryStringField="cakeNo" Type="Int32" />
        </SelectParameters>
    </asp:SqlDataSource>

    <asp:SqlDataSource ID="CakeTags" runat="server" 
        ConnectionString="<%$ ConnectionStrings:CakeConnection %>" 
        ProviderName="<%$ ConnectionStrings:CakeConnection.ProviderName %>" 
        SelectCommand="SELECT DISTINCT [ID], [TagName] FROM [CakeTagView] WHERE ([ID] = ?)">
        <SelectParameters>
            <asp:QueryStringParameter Name="ID" QueryStringField="cakeNo" Type="Int32" />
        </SelectParameters>
    </asp:SqlDataSource>

    <asp:SqlDataSource ID="NewCakeTags" runat="server" 
        ConnectionString="<%$ ConnectionStrings:CakeConnection %>" 
        ProviderName="<%$ ConnectionStrings:CakeConnection.ProviderName %>" 
        SelectCommand="SELECT [C_FID], [CountOfCT_FID], [TagName] FROM [TagCount] WHERE ([C_FID] = ?) ORDER BY RND([CountOfCT_FID]-Timer())">
        <SelectParameters>
            <asp:QueryStringParameter Name="C_FID" QueryStringField="cakeNo" Type="Int32" />
        </SelectParameters>
    </asp:SqlDataSource>

</p>
</asp:Content>
